'use strict';

module.exports = app => {
  const { STRING, INTEGER, DATE } = app.Sequelize;

  const Storebatch = app.model.define('store_batch', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    batch: { type: STRING(30), comment: '批次号' },
    goods_id: { type: STRING(36) },
    number: { type: INTEGER, comment: '每日序号' },
    ymd: { type: STRING(10), comment: '年-月-日' },
    corp_id: { type: INTEGER },
    description: STRING(200),
    created_at: DATE,
    updated_at: DATE,
  });

  Storebatch.associate = function() {
    app.model.Wms.Business.Storebatch.belongsTo(app.model.Wms.Business.Storegoods, { foreignKey: 'goods_id' });
    app.model.Wms.Business.Storebatch.belongsTo(app.model.Wms.Basic.Corp, { foreignKey: 'corp_id' });
  };

  return Storebatch;
};
